CreateObjcDelegate
Type
handler
Summary
Create an Objective-C object with LCB implementations of methods of a protocol.
Syntax
CreateObjcDelegate(<pProtocol>,<pHandlerMapping>)
Description
Use the CreateObjcDelegate handler to create instances of Objective-C
delegate classes with LCB implementations of protocol methods. Once
created these can be set in the usual way on an instance of the
appropriate class (by binding to -setDelegate:
), typically so that
callbacks triggered by user interaction with a widget can be handled in
LCB.
If any context is required to be passed as a parameter to the callback, use CreateObjcDelegateWithContext.
Some protocols consist of purely optional methods. In this case the
information about the protocol's methods are not available from the
objective-c runtime API. In this situation CreateObjcInformalDelegate
should be used instead.
Parameters
Name | Type | Description |
---|---|---|
pProtocol | The name of the protocol | |
pHandlerMapping | A mapping from the protocol's selector names to LCB handlers |
Examples
handler ControlIsValidObjectCallback(in pControl as ObjcId, in pObject as ObjcId) returns CSChar
return 1
end handler
public handler GetNSControlTextEditingDelegate() returns ObjcObject
return CreateObjcDelegate("NSControlTextEditingDelegate", \
{ "control:isValidObject:": \
ControlIsValidObjectCallback })
end handler
Related
handler: CreateObjcDelegateWithContext, CreateObjcInformalDelegate, CreateObjcInformalDelegateWithContext